home *** CD-ROM | disk | FTP | other *** search
- /****i* SOURCE_FILE/INFO
- *
- * NAME
- * EscapeUtils.js
- *
- * USAGE
- * Part of Netobjects JavaScript Library.
- *
- * COPYRIGHT
- * Copyright ⌐ 2002-2005 Website Pros, Inc.
- * All Rights Reserved.
- *
- * This is an unpublished work protected by Website Pros, Inc.
- * as a trade secret, and is not to be used or disclosed except as
- * expressly provided in a written license agreement executed by
- * you and Website Pros, Inc.
- *
- * <copyright@websitepros.com>
- *
- * NOTES
- * JavaScript code.
- *****/
-
- if (!IS.isModuleInitialized("IS.NOF.HTML.EscapeUtils"))
- {
- /****h* NOF_JavaScript_Library/NOF.HTML.EscapeUtils
- *
- * NAME
- * NOF.HTML.EscapeUtils
- *
- * DESCRIPTION
- *
- *
- * External dependencies:
- ****/
-
- function NOF_EscapeUtils(content){
- var escapeCharsHash = [ "/", "=", "\\r", "\\n", '"',"&","<",">"];
- var escapedCharsHash = ['/', '=', '
', '
', '"','&','<','>'];
-
- /*
- // "⌐","«","┤","½","╗","í", "┐", "└","α","┴","ß","┬","Γ","├","π","─","Σ","┼","σ","╞","µ",
- // "╟","τ","╨","≡", "╚","Φ","╔","Θ","╩", "Ω","╦","δ","╠","∞","═","φ","╬","ε","╧","∩","╤","±",
- // "╥","≥","╙","≤","╘","⌠","╒","⌡","╓","÷", "╪","°","┘", "∙","┌","·","█","√","▄","ⁿ","▌","²"," "
- //"▐","■","▀","º","╢","╡","ª","▒","╖","¿","╕", "¬","║","¼","¡","»","░","╣","▓","│","╝","╜","╛","╫",
- //"≈","ó","ú","ñ","Ñ"
- var escapedCharsCodeHash = ['©','<SUP>®</SUP>','´','«', '»',
- '¡','¿','À','à','Á','á','Â','â','Ã','ã','Ä','ä','Å','å',
- 'Æ','æ','Ç','ç','Ð',
- 'ð','È','è','É','é',
- 'Ê','ê','Ë','ë','Ì','ì','Í','í','Î',
- 'î','Ï','ï','Ñ','ñ','Ò','ò',
- 'Ó','ó','Ô','ô','Õ','õ','Ö','ö','Ø','ø',
- 'Ù','ù','Ú','ú','Û','û','Ü','ü','Ý',
- 'ý','ÿ','Þ','þ','ß','§','¶','µ','¦','±','·','¨',
- '¸','ª','º','¬','','¯','°','¹','²','³','¼','½','¾',
- '×','÷','¢','£','¤','¥'
- ];
- var escapeCharsCodeHash = [169, 174, 180, 171, 187, 161, 191,192, 224, 193, 225, 194, 226, 195, 227,
- 196, 228, 197, 229,198,230, 199, 231, 208, 240, 200,232,201,233,202,234,203,235,204,236,205,237,206,238,207,239,
- 209, 241, 210, 242, 211, 243, 212, 244, 213, 245, 214, 246, 216, 248, 217, 249, 218, 250, 219, 251, 220, 252, 221,253,255,
- 222, 254, 223, 167, 182, 181, 166, 177, 183, 168, 184, 170, 186, 172, 173, 175, 176, 185,178, 178,188, 189,190,215,
- 247, 162, 163,164,165 ];
- for (var i=0;i<escapeCharsCodeHash.length;i++) {
- var escapeCodeChar = escapeCharsCodeHash[i];
- re = eval ("\/" + String.fromCharCode(escapeCodeChar) + "\/g;");
- content = content.replace (re, escapedCharsCodeHash[i]);
- }
- */
-
- //replace any group '' by codifying each char
- var re = /\&\#/g;
- content = content.replace (re, "&#");
-
- for (var i=0;i<escapeCharsHash.length;i++) {
- var escapeChar = escapeCharsHash[i];
- re = eval ("\/" + escapeChar + "\/g;");
- content.replace (re, escapedCharsHash[i]);
- }
- for (var i =0;i<content.length;i++) {
- var ch = content.charAt(i);
- var code = content.charCodeAt(i);
- if (code > 127) {
- var re = eval ("\/" + ch + "\/g;");
- content = content.replace (re,"" + code + ";");
- }
- }
-
- return content;
- }
-
- NOF.HTML.__proto__.EscapeUtils = NOF_EscapeUtils;
- }
-